import {request} from './request.js'

//请求轮播图
export function getBanner(){
	return request({
		url:'/sliders',
		data: {
			//标记，放回不同平台的轮播图
		  platform: 'mini'
		},
		method: 'get'
	})
}
//请求产品列表
export function getCourses(data){
	return request({
		url:'/courses',
		method: 'get',
		data
	})
}
//请求产品详情
export function getCourseById(id){
	return request({
		url:'/course/'+id,
		method: 'get',
	})
}

//获取登录openid
export function loginCode(data){
	return request({
		url:'/wechat/mini/login',
		method: 'post',
		data
	})
}

//获取token
export function getToken(data){
	return request({
		url:'/login/wechatMini',
		method: 'post',
		data
	})
}

//绑定手机号登录
export function postPhone(data){
	return request({
		url:'/login/wechatMiniMobile',
		method: 'post',
		data
	})
}

//获取视频列表
export function getVideoList(){
	return request({
		url:'/videos',
		method: 'get',
	})
}
//获取课程信息
export function getVideoInfo(id){
	return request({
		url:`/video/${id}`,
		method: 'get',
	})
}
//获取视频
export function getVideo(id){
	return request({
		url:`/video/${id}/playinfo`,
		method: 'get'
	})
}

//播放统计
export function getVideoRecord(id,data){
	return request({
		url:`/video/${id}/record`,
		method: 'post',
		data
	})
}

//获取评论列表
export function getVideoComments(id,data){
	return request({
		url:`/video/${id}/comments`,
		method: 'get',
		data
	})
}
//视频评论
export function postVideoComments(id,data){
	return request({
		url:`/video/${id}/comment`,
		method: 'post',
		data
	})
}


//-----------------------------------------------------支付功能------------------------------------
// 创建购买课程订单
export function orderCouse(data){
	return request({
		url:`/order/course`,
		method: 'post',
		data
	})
}

//小程序支付
export function orderPay(data){
	return request({
		url:`/order/payment/wechat/mini`,
		method: 'post',
		data
	})
}

//喜欢课程
export function courseLike(id){
	return request({
		url:`/course/${id}/like`,
	})
}
